home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-10-26 | 1.6 KB | 42 lines | [TEXT/GEOL] |
- Item 1636699 26-Oct-89 12:40
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: Re: Re: A more useful IObject
-
- I think IObject should be used for essential object initialization. What I
- mean is the following:
-
- To do failure handling properly, you have to do the following steps when
- initializing an object.
-
- (1) Put the object in a state where it could be freed if the initialization
- failed. This generally involves putting NIL in the various fields of the
- object. (The Free method then uses FreeIfObject and DisposeIfHandle to free
- the data referenced by those fields.)
-
- (2) Call the initialization method of your superclass.
-
- (3) Do the rest of your initialization.
-
- If your object can't initialize itself, then it should free itself so that the
- code that created the object doesn't have to. (That's only one idea on how to
- handle this, but it seems the most convenient for programmers using your
- classes.)
-
- If you follow that convention, then step 2 might fail, which would result in
- your object being freed. That's why it is important that step 1 gets the
- object into a consistent state, and that step 1 does not fail.
-
- As part of step 3, you should set up a failure handler, if any part of step 3
- could fail. That handle should simply call Free.
-
- IObject could be used to satisfy step 1, if it was called automatically when
- the object was created by New. Since this generally involves setting fields to
- NIL, it is not necessary for IObject to have any parameters.
-
- Larry Rosenstein
-
-